#include "ChatServer.h"

void ConnectClient(struct sockaddr_in servaddr)
{
sockfd=socket(AF_INET,SOCK_STREAM,0);
if(sockfd==-1)
{
cout<<"socket creation failed..."<<endl;
exit(0);
}
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family=AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
servaddr.sin_port=htons(PORT);
if((bind(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)))!=0)
{cout<<"bind failed"<<endl;
exit(0);
}
cout<<"listening..."<<endl;
if((listen(sockfd,MAX_CLIENT))!=0)
{
cout<<"listen failed"<<endl;
exit(0);
}
}
